
package cn.com.pusai.core.util;

import cn.com.pusai.core.util.StringUtil;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

public class StrUtil extends StringUtil
{

	public StrUtil()
	{
	}

	public static String strCodeFormat(String str)
		throws UnsupportedEncodingException
	{
		if (str == null || str.equals(""))
			return "";
		String encoding = "";
		if (str.equals(new String(str.getBytes(), "utf-8")))
			encoding = URLDecoder.decode(str, "UTF-8");
		else
		if (str.equals(new String(str.getBytes(), "ISO8859-1")))
			encoding = URLDecoder.decode(str, "UTF-8");
		else
		if (str.equals(new String(str.getBytes(), "GBK")))
			encoding = URLDecoder.decode(str, "UTF-8");
		else
		if (str.equals(new String(str.getBytes(), "gb2312")))
			encoding = URLDecoder.decode(str, "UTF-8");
		else
			encoding = new String(str.getBytes("ISO8859-1"), "UTF-8");
		return encoding;
	}
}
